package Array;

import java.util.Arrays;

//                                    数组传参
public class Test3 {
    public static void func1(int[] arr){
        System.out.println(arr.length);
        arr[0] = 100;
        System.out.println(Arrays.toString(arr));
    }

    public static int[] func2(){
        int[] arr = new int[]{1, 2, 3};
        return arr;
    }

    public static void Swap(int[] arr){
        int tmp = 0;
        tmp = arr[0];
        arr[0] = arr[1];
        arr[1] = tmp;
    }
    public static void main(String[] args) {
        //
        int[] arr1 = new int[]{1, 2, 3, 4, 5};
        func1(arr1);

        //练习
        //用函数交换两个数的值
        int[] arr2 = new int[]{1, 2};
        System.out.println(Arrays.toString(arr2));
        Swap(arr2);
        System.out.println(Arrays.toString(arr2));

        //
        int[] arr3 = func2();
        System.out.println(Arrays.toString(arr3));
    }
}
